package com.jin.spirng_boot_learn.socket;

import java.net.ServerSocket;
import java.net.Socket;

public class server {

    public static void main(String[] args) throws Exception{
        //服务端在20006端口监听客户端请求的TCP连接
        try (ServerSocket server = new ServerSocket(8080)) {
            Socket client = null;
            boolean f = true;
            while (f) {
                //等待客户端的连接，如果没有获取连接
                client = server.accept();
                System.out.println("与客户端连接成功！");
                //为每个客户端连接开启一个线程
               new ServerThread(client).run();
               Thread.sleep(1000*100);
            }
            server.close();
        }
    }
}
